package IO;

import javax.print.DocFlavor;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;
public class Test2 {
    public static void main(String[] args) throws IOException {
       /* FileOutputStream fos = new FileOutputStream("./File/osw.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);*/
        FileOutputStream fos = new FileOutputStream("./File/pw.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.print("请输入想要输入的数据(exit退出)：");
            String user =scanner.nextLine();
            if(!("exit".equalsIgnoreCase(user))){
                pw.write(user);
                System.out.println("数据已经写入！！");
                continue;
            }else{
                System.out.println("已退出");
                pw.close();
                break;
            }

        }




    }
}
